﻿using System;
using Microsoft.Office.Interop.Outlook;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace KOPLibrary.DataManagement
{
    public static class OutlookManager
    {

        public static AbstractData RetreiveContacts()
        {
            Application app = new Microsoft.Office.Interop.Outlook.Application();
            Items contacts = app.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Items.Restrict("[MessageClass]='IPM.Contact'");
            
            ContactItem item = (ContactItem)contacts.GetFirst();
            
            
            
            AbstractData result = new AbstractData();
            result.Columns.AddRange(new string[] 
                    {   "Ad ve Soyadı", "E-Posta Adresi", 
                        "İş Telefonu","İş Adresi","İş Adresi Şehir","İş Adresi Ülke",
                        "Ev Telefonu","Ev Adresi","Ev Adresi Şehir","Ev Adresi Ülke",
                        "Not"});
            while (item != null)
            {
                result.Add(new object []
                { 
                      item.FullName, item.Email1Address, 
                      item.Business2TelephoneNumber, item.BusinessAddress,item.BusinessAddressCity,item.BusinessAddressCountry,
                    item.Home2TelephoneNumber,item.HomeAddress,item.HomeAddressCity,item.HomeAddressCountry,
                    item.Body

                });
                item = (ContactItem)contacts.GetNext();
            }
            app.Quit();
            return result;
        }
    }
}
